home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Compute! Gazette 1987 February
/
1987-02.d64
/
data format-1
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-09-20
|
579b
|
28 lines
398 rem * program one *
399 rem * decimal format demo *
400 print"[147]";
410 c1=.5:c2=1:c3=100:pn=1000:nn=-1000
420 printspc(6)"raw data"spc(7)"formatted data"
430 printspc(6)"[163][163][163][163][163][163][163][163]"spc(7)"[163][163][163][163][163][163][163][163][163][163][163][163][163][163]"
440 fori=1to20
450 s=rnd(-ti)
460 v=(nn-pn+c2)*rnd(1)+pn
470 gosub5000
480 printspc(4)v;tab(24)n$
490 next
500 poke198,0
510 printspc(10)"hit a key for more"
520 getk$:ifk$=""then520
530 goto400
4999 rem *** decimal format routine ***
5000 n$=str$(int(v*c3+c1)/c3)
5010 lo=len(n$)
5020 forj=2tolo
5030 ifmid$(n$,j,1)="."thenfr=lo-j:j=lo
5040 next
5050 onfr+c2goto5070,5080,5090
5060 n$=left$(n$,lo-fr+2):goto5090
5070 n$=n$+".00":return
5080 n$=n$+"0"
5090 fr=0:return